﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Xml.Linq;
using System.Windows.Forms;
using DicitiControlLib;
using AxDicitiControlLib;
using System.IO;
using System.Runtime.InteropServices;
using DevExpress.XtraNavBar;
using DevExpress.XtraBars.Ribbon;
using Emergency.Controls;
using FormLib.Forms;
namespace Emergency
{
    public partial class FormMain : Form
    {
        private PlanManagement m_planManagementControl = null;
        private ExerciseEntrance m_exerciseEntrance = null;
        private ExercisePane m_exercisePane = null; 

        
        public FormMain()
        {
            InitializeComponent();

           
           
        }
        //启动后首先脚本管理
        private void FormMain_Load(object sender, EventArgs e)
        {
            m_planManagementControl = new PlanManagement();
            
            panelContainer.Controls.Add(m_planManagementControl);
            m_planManagementControl.Dock = DockStyle.Fill;

            m_planManagementControl.OnStartClicked += new FormButtonClickedHandler(m_planManagementControl_OnStartClicked);
        }


        //进入演练
        void m_planManagementControl_OnStartClicked(object sender, EventArgs e)
        {
            //if (m_exerciseEntrance == null)
            //{
                m_exerciseEntrance = new ExerciseEntrance();
                m_exerciseEntrance.OnCommandClicked += new FormButtonClickedHandler(m_exerciseEntrance_OnCommandClicked);
                m_exerciseEntrance.OnDispatchClicked += new FormButtonClickedHandler(m_exerciseEntrance_OnDispatchClicked);
                m_exerciseEntrance.OnHandlerClicked += new FormButtonClickedHandler(m_exerciseEntrance_OnHandlerClicked);
                m_exerciseEntrance.OnMedicClicked += new FormButtonClickedHandler(m_exerciseEntrance_OnMedicClicked);
                m_exerciseEntrance.OnMonitorClicked += new FormButtonClickedHandler(m_exerciseEntrance_OnMonitorClicked);
                m_exerciseEntrance.OnProfessionClicked += new FormButtonClickedHandler(m_exerciseEntrance_OnProfessionClicked);
           // }
               
            panelContainer.Controls.Clear();
            panelContainer.Controls.Add(m_exerciseEntrance);
            m_exerciseEntrance.Dock = DockStyle.Fill;

           
        }

        #region 人员入口
        void m_exerciseEntrance_OnProfessionClicked(object sender, EventArgs e)
        {
            for (int i = 0; i < ribbonMain.Pages.Count; i++) 
            {
                RibbonPage rp = ribbonMain.Pages[i];
                if (rp == ribbonPageGeneral || rp == ribbonPageProfession)
                {
                    rp.Visible = true;
                }
                else
                    rp.Visible = false;
               

            }
            //if (m_exercisePane == null)
                m_exercisePane = new ExercisePane();
            panelContainer.Controls.Clear();
            panelContainer.Controls.Add(m_exercisePane);
            m_exercisePane.Dock = DockStyle.Fill;
        }

        void m_exerciseEntrance_OnMonitorClicked(object sender, EventArgs e)
        {
            for (int i = 0; i < ribbonMain.Pages.Count; i++)
            {
                RibbonPage rp = ribbonMain.Pages[i];
                if (rp == ribbonPageGeneral || rp == ribbonPageMonitor)
                {
                    rp.Visible = true;
                }
                else
                    rp.Visible = false;
               
            }
           // if (m_exercisePane == null)
                m_exercisePane = new ExercisePane();
            panelContainer.Controls.Clear();
            panelContainer.Controls.Add(m_exercisePane);
            m_exercisePane.Dock = DockStyle.Fill;
        }

        void m_exerciseEntrance_OnMedicClicked(object sender, EventArgs e)
        {
            for (int i = 0; i < ribbonMain.Pages.Count; i++)
            {
                RibbonPage rp = ribbonMain.Pages[i];
                if (rp == ribbonPageGeneral || rp == ribbonPageMedical)
                {
                    rp.Visible = true;
                }
                else
                    rp.Visible = false;

            }
            //if (m_exercisePane == null)
                m_exercisePane = new ExercisePane();
            panelContainer.Controls.Clear();
            panelContainer.Controls.Add(m_exercisePane);
            m_exercisePane.Dock = DockStyle.Fill;
        }

        void m_exerciseEntrance_OnHandlerClicked(object sender, EventArgs e)
        {
            for (int i = 0; i < ribbonMain.Pages.Count; i++)
            {
                RibbonPage rp = ribbonMain.Pages[i];
                if (rp == ribbonPageGeneral || rp == ribbonPageHandler)
                {
                    rp.Visible = true;
                }
                else
                    rp.Visible = false;

            }
            //if (m_exercisePane == null)
                m_exercisePane = new ExercisePane();
            panelContainer.Controls.Clear();
            panelContainer.Controls.Add(m_exercisePane);
            m_exercisePane.Dock = DockStyle.Fill;
        }

        void m_exerciseEntrance_OnDispatchClicked(object sender, EventArgs e)
        {
            for (int i = 0; i < ribbonMain.Pages.Count; i++)
            {
                RibbonPage rp = ribbonMain.Pages[i];
                if (rp == ribbonPageGeneral || rp == ribbonPageLogitics)
                {
                    rp.Visible = true;
                }
                else
                    rp.Visible = false;

            }
           // if (m_exercisePane == null)
                m_exercisePane = new ExercisePane();
            panelContainer.Controls.Clear();
            panelContainer.Controls.Add(m_exercisePane);
            m_exercisePane.Dock = DockStyle.Fill;
        }

        void m_exerciseEntrance_OnCommandClicked(object sender, EventArgs e)
        {
            for (int i = 0; i < ribbonMain.Pages.Count; i++)
            {
                RibbonPage rp = ribbonMain.Pages[i];
                if (rp == ribbonPageGeneral || rp == ribbonPageCommand)
                {
                    rp.Visible = true;
                }
                else
                    rp.Visible = false;

            }
           // if (m_exercisePane == null)
                m_exercisePane = new ExercisePane();
            panelContainer.Controls.Clear();
            panelContainer.Controls.Add(m_exercisePane);
            m_exercisePane.Dock = DockStyle.Fill;
        }
        #endregion 人员入口


        private void rbExit_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            Application.Exit();
        }

        private void barItemStopExercise_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            panelContainer.Controls.Clear();
            panelContainer.Controls.Add(m_planManagementControl);
            m_planManagementControl.Dock = DockStyle.Fill;
        }

        private void barItemCommandCaseInfo_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            FrmShowPlanInfo frmShowInfo = new FrmShowPlanInfo();
            frmShowInfo.ShowDialog();
        }

        private void barButtonItem17_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            FrmRescueForce frmRescueForce = new FrmRescueForce();
            frmRescueForce.ShowDialog();

        }

        private void btnDrawAlertArea_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            if (m_exercisePane != null) 
            {
                m_exercisePane.SetDrawMode("effectedArea");
            }
        }

        private void btnCreateRoute_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            if (m_exercisePane != null)
            {
                m_exercisePane.SetDrawMode("route");
            }
        }

        private void btnSetModel_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            if (m_exercisePane != null)
            {
                m_exercisePane.SetDrawMode("model");
            }
        }

        private void btnCreateDoc_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            string fileName = System.IO.Path.Combine(Application.StartupPath,@"报告.docx");
            System.Diagnostics.Process.Start(fileName);
        }

        private void btnMonitorShowInfo_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            FrmShowPlanInfo frmShowInfo = new FrmShowPlanInfo();
            frmShowInfo.ShowDialog();
        }

        private void btnHandleShowInfo_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            FrmShowPlanInfo frmShowInfo = new FrmShowPlanInfo();
            frmShowInfo.ShowDialog();
        }

        private void btnDispatchShowInfo_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            FrmShowPlanInfo frmShowInfo = new FrmShowPlanInfo();
            frmShowInfo.ShowDialog();
        }

        private void btnMedicShowInfo_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            FrmShowPlanInfo frmShowInfo = new FrmShowPlanInfo();
            frmShowInfo.ShowDialog();
        }

        private void btnProfessionShowInfo_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            FrmShowPlanInfo frmShowInfo = new FrmShowPlanInfo();
            frmShowInfo.ShowDialog();
        }

        private void btnMonitorMethods_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            MonitoringMethodFrom frmMethrod = new MonitoringMethodFrom();
            frmMethrod.ShowDialog();
        }

        private void btnExpandSimulation_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            //dispersionModelResult frmResult = new dispersionModelResult();
            //frmResult.ShowDialog();
        }

        private void btnMonitorCallHelp_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            askHelpForm frmCallHelp = new askHelpForm();
            frmCallHelp.ShowDialog();
        }

        private void btnCommandCallHelp_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            askHelpForm frmCallHelp = new askHelpForm();
            frmCallHelp.ShowDialog();
        }

        private void btnHandleCallHelp_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            askHelpForm frmCallHelp = new askHelpForm();
            frmCallHelp.ShowDialog();
        }

        private void btnDispatchCallHelp_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            askHelpForm frmCallHelp = new askHelpForm();
            frmCallHelp.ShowDialog();
        }

        private void btnMedicCallHelp_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            askHelpForm frmCallHelp = new askHelpForm();
            frmCallHelp.ShowDialog();
        }

        private void btnProfessionCallHelp_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            askHelpForm frmCallHelp = new askHelpForm();
            frmCallHelp.ShowDialog();
        }

        private void btnMonitorPlan_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            monitoringResult frmPlan = new monitoringResult();
            frmPlan.ShowDialog();

        }

        private void btnHandleMethods_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            handleMethodForm frmMethods = new handleMethodForm();
            frmMethods.ShowDialog();
        }

        private void btnHandlePlan_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            handleResultForm frmPlan = new handleResultForm();
            frmPlan.ShowDialog();
        }

        private void btnRepository_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            resourceDispatchForm frmmResource = new resourceDispatchForm();
            frmmResource.ShowDialog();
        }

        private void btnSuggest_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            expertSuggest frmSuggest = new expertSuggest();
            frmSuggest.ShowDialog();
        }

        private void btnAtmosphereExpand_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            dispersionModelSettingForm frmSettings = new dispersionModelSettingForm();
            frmSettings.ShowDialog();
        }

        private void btnMedicPlan_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            AidForm frmAid = new AidForm();
            frmAid.ShowDialog();
        }

           
          

   

  
    }
}
